package com.gopay.common.rcs.manager.transadmit.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.gopay.common.constants.txncd.IntTxnCd;
import com.gopay.common.constants.txncd.MerTxnCd;
import com.gopay.common.domain.rcs.transadmit.RcsTransAdmittanceConfCust;
import com.gopay.common.rcs.dao.transadmit.RcsTransAdmitConfDAO;
import com.gopay.common.rcs.manager.transadmit.RcsTransAdmitConfManager;
/**
 * 交易准入Manager
 * @author lizheng
 *
 */
@Repository("rcsTransAdmitConfManager")
public class RcsTransAdmitConfManagerImpl implements RcsTransAdmitConfManager {
	@Resource(name = "rcsTransAdmitConfDAO")
	private RcsTransAdmitConfDAO rcsTransAdmitConfDAO;

	static private Map<String, String> txnCdMap = new HashMap<String, String>();
	static {
		/*  网关批量付款到银行  songfengli 20170703 start*/
		txnCdMap.put(MerTxnCd._4035.value, IntTxnCd._00700.value);
		/*  网关批量付款到银行  songfengli 20170703 end*/
	    txnCdMap.put(MerTxnCd._4025.value, IntTxnCd._00700.value);
	    txnCdMap.put(MerTxnCd._0618.value, IntTxnCd._00700.value);//云账户付款到银行权限备案
        txnCdMap.put(MerTxnCd._8803.value, IntTxnCd._00100.value);
        txnCdMap.put(MerTxnCd._8802.value, IntTxnCd._00100.value);
        txnCdMap.put(MerTxnCd._8801.value, IntTxnCd._00100.value);
		// 快捷二次支付API申请 add by sh.jiao 20170331
		txnCdMap.put(MerTxnCd._8805.value, IntTxnCd._00100.value);
        txnCdMap.put(MerTxnCd._NC01.value, IntTxnCd._00604.value);
        txnCdMap.put(MerTxnCd._5556.value, IntTxnCd._00603.value);
        //委托代收银行卡鉴权 add by pansc at 20161221
        txnCdMap.put(MerTxnCd._DS01.value, IntTxnCd._00664.value);
        //微信支付加入 zhoutong add at 20160811
        //txnCdMap.put(MerTxnCd._SC01.value, IntTxnCd._00100.value);
        //txnCdMap.put(MerTxnCd._SC02.value, IntTxnCd._00100.value);
		//微信公众号扫码支付加入 add by jianglijun 20161010
        //txnCdMap.put(MerTxnCd._SC03.value, IntTxnCd._00100.value);
		/*  基金申认购权限备案添加  baiyunpeng 20160819 start*/
		txnCdMap.put(MerTxnCd._8204.value, IntTxnCd._02004.value);
		/*  基金申认购权限备案添加  baiyunpeng 20160819 end*/
		//委托代收交易 add by lx at 2016-12-22 16:20:02
        txnCdMap.put(MerTxnCd._DS05.value, IntTxnCd._00666.value);
        //委托授权申请 add by zhuliang 20161222
        txnCdMap.put(MerTxnCd._DS03.value, IntTxnCd._00666.value);
        //委托授权确认 add by zhuliang 20161222
        txnCdMap.put(MerTxnCd._DS04.value, IntTxnCd._00666.value);
        //交易拆分
        txnCdMap.put(MerTxnCd._SC01.value, IntTxnCd._02301.value);
        txnCdMap.put(MerTxnCd._SC02.value, IntTxnCd._02301.value);
		//微信公众号扫码支付加入 add by jianglijun 20161010
        txnCdMap.put(MerTxnCd._SC03.value, IntTxnCd._02301.value);
        //条码支付 add by xuanguanghai 20170525
        txnCdMap.put(MerTxnCd._MP01.value, IntTxnCd._02301.value);
        txnCdMap.put(MerTxnCd._MP02.value, IntTxnCd._02302.value);
        //直接代收 add by sh.jiao 20171024
		txnCdMap.put(MerTxnCd._ZDS1.value, IntTxnCd._00666.value);
		//云账户提现，开户，转账添加权限备案校验 add by liuyong 20171123
		//云账户免密提现
		txnCdMap.put(MerTxnCd._0624.value,IntTxnCd._00800.value);
		//云账户后台开户
		txnCdMap.put(MerTxnCd._0619.value,IntTxnCd._01802.value);
		//云账户卡信息管理
		txnCdMap.put(MerTxnCd._0620.value,IntTxnCd._01802.value);
		//云账户转账
		txnCdMap.put(MerTxnCd._0613.value,IntTxnCd._01812.value);
		
		txnCdMap.put(MerTxnCd._0600.value,IntTxnCd._00100.value);

	}
	@Override
	public RcsTransAdmittanceConfCust findByCustIdAndMerTxnCd(String custId, String merTxnCd) {
		List<RcsTransAdmittanceConfCust> list = rcsTransAdmitConfDAO.findByCustIdAndIntTxnCd(custId, txnCdMap.get(merTxnCd));
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}
	@Override
	public RcsTransAdmittanceConfCust findByCustIdAndIntTxnCd(String custId, String intTxnCd) {
		List<RcsTransAdmittanceConfCust> list = rcsTransAdmitConfDAO.findByCustIdAndIntTxnCd(custId, intTxnCd);
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}
	@Override
	public void save(RcsTransAdmittanceConfCust conf) {
		rcsTransAdmitConfDAO.save(conf);
	}
	@Override
	public void update(RcsTransAdmittanceConfCust conf) {
		rcsTransAdmitConfDAO.update(conf);
	}

}
